package com.fwtai.api;

import com.fwtai.bean.PageFormData;
import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 律卡访问数据库
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2021-08-12 11:45:11
 * @QQ号码 444141300
 * @Email service@yinlz.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class ApiLawyerCardDao{

    @Resource
    private DaoHandle dao;

    public int add(final PageFormData formData){
        return dao.execute("api_lawyer_card.add",formData);
    }

    public String queryExistById(final String loginId){
        return dao.queryForString("api_lawyer_card.queryExistById",loginId);
    }

    public int edit(final PageFormData formData){
        return dao.execute("api_lawyer_card.edit",formData);
    }

    public HashMap<String,Object> queryById(final String loginId){
        return dao.queryForHashMap("api_lawyer_card.queryById",loginId);
    }

    public int delById(final String loginId){
        return dao.execute("api_lawyer_card.delById",loginId);
    }

    public List<Map<String,Object>> getCardType(){
        return dao.queryForListMap("api_lawyer_card.getCardType");
    }

    public HashMap<String,Object> queryCardInfo(final String code){
        return dao.queryForHashMap("api_lawyer_card.queryCardInfo",code);
    }

    @Transactional
    public int addActive(final PageFormData formData){
        final int rows = dao.execute("api_lawyer_card.add",formData);
        dao.execute("api_lawyer_card.updateCard",formData);
        return rows;
    }
}